/* vuex仓库管理模块 */
import Vue from "vue";
import Vuex from "vuex";
// 仓库模块引入
import home from "./home";
import search from "./search";
import detail from "./detail";
import shopcart from "./shopcart";
import user from "./user";
import trade from "./trade";

// 刷新数据不丢失
import createPersistedState from "vuex-persistedstate";

Vue.use(Vuex);

export default new Vuex.Store({
  modules: {
    home,
    search,
    detail,
    shopcart,
    user,
    trade,
  },

  plugins: [
    createPersistedState({
      storage: window.sessionStorage,
      path: ["shopcart"],  //刷新后数据不丢失（原理是保存在localStorage或sessionStorage）
    }),
  ],
});
